package Demo4;

abstract class Animal{
    public  String name;
    public int age;

    public Animal() {
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat(){
    }

}
interface IFly
{
    void fly();
}

interface IRun{
    void Run();
}

interface ISwim{
    void swim();
}

class Dog extends Animal implements IRun{

    Dog(String name,int age){
        super(name,age);
    }
    @Override
    public void Run() {
        System.out.println(this.name + " 正在跑");
    }

    @Override
    public void eat() {
        System.out.println(this.name + "正在吃狗粮");
    }
}
class Frog extends Animal implements IRun,ISwim{
    public Frog() {
    }

    public Frog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name + "正在吃青哇粮");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在蛙泳");

    }

    @Override
    public void Run() {
        System.out.println(this.name + "正在蛙跳");

    }
}
class Duck extends Animal implements IRun,ISwim,IFly{
    public Duck() {
    }

    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name + "正在吃鸭粮");
    }

    @Override
    public void fly() {
        System.out.println(this.name + "正在用翅膀飞飞飞飞");
    }

    @Override
    public void Run() {
        System.out.println(this.name + "正在用两只脚脚跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在用两只脚脚游泳");
    }
}

class Roboot implements IRun{
    public Roboot() {
    }

    @Override
    public void Run() {
        System.out.println("机器人正在走路");
    }
}

public class Test {

    public static void Swimming(ISwim iSwim){
        iSwim.swim();
    }
    public static void Running(IRun iRun){
        iRun.Run();
    }
    public static void Flying(IFly ifly){
        ifly.fly();
    }
    public static void func(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        Running(new Duck("唐老鸭",20));
        Running(new Dog("二狗子",20));
        Running(new Frog("青蛙",20));
        Running(new Roboot());

        Flying(new Duck("唐老鸭",20));
        //Flying(new Dog("二狗子",20));
        //Flying(new Frog("青蛙",20));

        Swimming(new Duck("唐老鸭",20));
        //Swimming(new Dog("二狗子",20));
        Swimming(new Frog("青蛙",20));
    }
    public static void main2(String[] args) {
        func(new Duck("唐老鸭",20));
        func(new Dog("二狗子",20));
        func(new Frog("青蛙",20));
    }
}
